﻿Imports Exp.DATA_Service
Imports Exp.Model
Imports Exp.DATA_Service.Exp.DATA_Service

Public Class Resort
    Inherits BasePage
    Const MENUNAME As String = "RESORT"


#Region "Event"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Session("USER") Is Nothing Then
                Response.Redirect("~/login.aspx")
            Else
                Dim objUser As REM_User = CType(Session("USER"), REM_User)

                Dim objUSV As New Exp.DATA_Service.User_Service
                If Not objUSV.isHasRight(objUser.User_ID, MENUNAME) Then
                    Session("USER") = Nothing
                    Session.Clear()
                    Response.Redirect("~/login.aspx")
                End If

            End If
            BindData()
            BindConTrol()
            BindConTrolSearch()
            GetDataTable()
        End If

    End Sub
    Protected Sub btn_Save_Click(sender As Object, e As EventArgs) Handles btn_Save.Click
        Dim sError As String = ""

        If HDFieldResortID.Value = "" Then
            If CheckInsert(sError) Then
                SaveResort()
                SaveResortSeason()
                BindData()
                ClearControlResort()
                MultiView1.ActiveViewIndex = 0
            End If
        Else
            If CheckInsert(sError) Then
                EditResort()
                SaveResortSeason()
                BindData()
                ClearControlResort()
                MultiView1.ActiveViewIndex = 0
            End If
        End If
    End Sub
    Protected Sub btn_AddSeason_Click(sender As Object, e As EventArgs) Handles btn_AddSeason.Click
        Dim iseason As Integer = ddl_Season.SelectedValue
        Dim iResort As Integer = 0
        If txtFromDate.Text.Trim = "" Or txtToDate.Text.Trim = "" Then
            JavaScript.AlertMessage(Me.Page, "Please insert start date and end date.")
            BindListData("edit")
            Return
        End If
        If CheckDuplicateInsert(ddl_Season.SelectedItem.ToString) Then
            JavaScript.AlertMessage(Me.Page, "Season : " & ddl_Season.SelectedItem.ToString & " is already")
            BindListData("edit")
            Return
        End If

        Dim dtStartDate As Date = GetDataUtil.CDateToDB(txtFromDate.Text)
        Dim dtEndDate As Date = GetDataUtil.CDateToDB(txtToDate.Text)
        If dtStartDate > dtEndDate Then
            JavaScript.AlertMessage(Me.Page, "start date and end date have conflict.")
            BindListData("edit")
            Return
        End If

        If Not HDFieldResortID.Value = "" Then
            iResort = HDFieldResortID.Value
        End If

        dtStartDate = GetDataUtil.CDateToDB(txtFromDate.Text)
        dtEndDate = GetDataUtil.CDateToDB(txtToDate.Text)
        AddListRow(iseason, ddl_Season.SelectedItem.ToString, dtStartDate, dtEndDate)
        BindListData("edit")
        ClearControl()
        'If CheckIDExistingResortSeason(iResort, iseason) Then

        'End If

    End Sub
    Private Sub btn_Cancel_Click(sender As Object, e As EventArgs) Handles btn_Cancel.Click
        BindData()
    End Sub
    Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btn_search.Click
        BindDataSearch()
    End Sub
    Protected Sub btn_Add_Click(sender As Object, e As EventArgs) Handles btn_Add.Click
        ClearControlAdd()
    End Sub
#End Region
#Region "Function"
    Sub SaveResort()
        Dim objUser As REM_User = CType(Session("USER"), REM_User)
        Dim objREM_Resort As New REM_Resort
        If CheckNameExisting(txtResortName.Text, 0) Then
            lblStatus.Text = "Name existing, please try again "
            Return
        Else
            lblStatus.Text = ""
        End If
        Dim Resort_service As New Resort_service
        Dim iResort As Integer = Resort_service.GetLastID()

        objREM_Resort.Resort_ID = iResort
        objREM_Resort.ResortName = txtResortName.Text
        objREM_Resort.Brand_ID = ddl_Brand.SelectedValue
        objREM_Resort.Country_ID = ddl_Country.SelectedValue
        objREM_Resort.isActive = ddl_Status.SelectedValue
        objREM_Resort.UpdateDate = CType(Now, Date)
        objREM_Resort.CreateDate = CType(Now, Date)
        objREM_Resort.CreateUser = objUser.User_ID
        objREM_Resort.UpdateUser = objUser.User_ID
        objREM_Resort.Address = txtAddress.Text
        objREM_Resort.Description = txtDescription.Text
        Resort_service.Add(objREM_Resort)
        HDFieldResortID.Value = iResort
    End Sub
    Sub EditResort()
        Dim objUser As REM_User = CType(Session("USER"), REM_User)
        Dim objREM_Resort As New REM_Resort
        Dim objEXP_Select_REM_User_Result As New EXP_Select_REM_User_Result
        If CheckNameExisting(txtResortName.Text, HDFieldResortID.Value) Then
            lblStatus.Text = "Name existing, please try again "
            Return
        Else
            lblStatus.Text = ""
        End If
        Dim Resort_service As New Resort_service
        Dim iResort As Integer = HDFieldResortID.Value

        objREM_Resort.Resort_ID = iResort
        objREM_Resort.ResortName = txtResortName.Text
        objREM_Resort.Brand_ID = ddl_Brand.SelectedValue
        objREM_Resort.Country_ID = ddl_Country.SelectedValue
        objREM_Resort.isActive = ddl_Status.SelectedValue
        objREM_Resort.UpdateDate = CType(Now, Date)
        objREM_Resort.UpdateUser = objUser.User_ID
        objREM_Resort.Address = txtAddress.Text
        objREM_Resort.Description = txtDescription.Text
        Resort_service.Edit(objREM_Resort)
    End Sub
    Sub SaveResortSeason()
        Dim dt As New DataTable
        dt = GetListData()
        Dim ResortSeason_Service As New ResortSeason_service
        'Delete Visitor

        ResortSeason_Service.DeleteAll(HDFieldResortID.Value)
        For Each dr As DataRow In dt.Rows
            Dim dating As New Date(2015, 2, 1)
            Dim dating2 As New Date(2015, 2, 28)
            Dim REM_ResortSeason As New REM_ResortSeason
            REM_ResortSeason.Resort_ID = HDFieldResortID.Value
            REM_ResortSeason.Season_ID = dr("ListData_SeasonID").ToString
            REM_ResortSeason.StartDate = dr("ListData_StartDate").ToString
            REM_ResortSeason.EndDate = dr("ListData_EndDate").ToString
            ResortSeason_Service.Add(REM_ResortSeason)
        Next

    End Sub
    Sub BindConTrol()
        BindBrand()
        BindCountry()
        BindStatus()
        BindSeason()
    End Sub
    Sub BindConTrolSearch()
        BindBrandSearch()
        BindCountrySearch()
    End Sub
    Sub BindBrand()
        Dim REM_Brand As New List(Of REM_Brand)
        Dim Brand_Service As New Brand_Service
        REM_Brand = Brand_Service.GetAll()
        REM_Brand.Distinct()
        ddl_Brand.DataSource = REM_Brand
        ddl_Brand.DataTextField = "BrandName"
        ddl_Brand.DataValueField = "Brand_ID"
        ddl_Brand.DataBind()
    End Sub
    Sub BindCountry()
        Dim REM_Country As New List(Of REM_Country)
        Dim Country_service As New Country_Service
        REM_Country = Country_service.GetAll()
        REM_Country.Distinct()
        ddl_Country.DataSource = REM_Country
        ddl_Country.DataTextField = "CountryName"
        ddl_Country.DataValueField = "Country_ID"
        ddl_Country.DataBind()
    End Sub
    Sub BindStatus()
        'ddl_Status.Items.Clear()
        'ddl_Status.Items.Add("Active")
        'ddl_Status.Items.Add("InActive")
        ddl_Status.SelectedValue = ddl_Status.Items.FindByText("Active").Value
    End Sub
    Sub BindDataSearch()
        Dim Resort_service As New Resort_service
        Dim objREM_Resort As New List(Of REM_Resort)
        objREM_Resort = Resort_service.GetAll()

        If ddlBrandSearch.SelectedValue <> "" Then
            objREM_Resort = objREM_Resort.Where(Function(p) p.Brand_ID = ddlBrandSearch.SelectedValue).ToList()
        End If
        If ddlCountrySearch.SelectedValue <> "" Then
            objREM_Resort = objREM_Resort.Where(Function(p) p.Country_ID = ddlCountrySearch.SelectedValue).ToList()
        End If
        If ddl_Status.SelectedValue <> "" Then
            objREM_Resort = objREM_Resort.Where(Function(p) p.isActive = ddl_Status.SelectedValue).ToList()
        End If
        gv_Data.DataSource = objREM_Resort
        gv_Data.DataBind()
    End Sub
    Sub BindData()
        Dim Resort_service As New Resort_service
        Dim objREM_Resort As New List(Of REM_Resort)
        objREM_Resort = Resort_service.GetAll()
        gv_Data.DataSource = objREM_Resort
        gv_Data.DataBind()
    End Sub
    Sub BindDataView(ByVal iResortID As Integer)
        Dim REM_Resort As New REM_Resort
        Dim Resort_Service As New Resort_service
        REM_Resort = Resort_Service.GetByID(iResortID)
        If Not REM_Resort Is Nothing Then
            lblResortID.Text = REM_Resort.Resort_ID
            lblResortName.Text = REM_Resort.ResortName
            Dim REM_Country As New REM_Country
            Dim Country_service As New Country_Service
            lblCountry.Text = Country_service.GetByID(REM_Resort.Country_ID).CountryName
            lblAddress.Text = REM_Resort.Address
            lblDescription.Text = REM_Resort.Description
            Dim REM_Brand As New REM_Brand
            Dim Brand_Service As New Brand_Service
            lblBrand.Text = Brand_Service.GetByID(REM_Resort.Brand_ID).BrandName
            If REM_Resort.isActive Then
                lblStatus.Text = "Active"
            Else
                lblStatus.Text = "InActive"
            End If
            lblUpdateDate.Text = REM_Resort.UpdateDate
            Dim REM_User As New REM_User
            Dim User_Service As New User_Service
            lblUpdateUser.Text = User_Service.GetByID(REM_Resort.UpdateUser).UserName
        End If
    End Sub
    Sub BindSeason()
        Dim REM_Season As New List(Of REM_Season)
        Dim Season_service As New Season_Service
        REM_Season = Season_service.GetAll()
        REM_Season.Distinct()
        ddl_Season.DataSource = REM_Season
        ddl_Season.DataTextField = "SeasonCode"
        ddl_Season.DataValueField = "Season_ID"
        ddl_Season.DataBind()
    End Sub
    Sub BindBrandSearch()
        Dim REM_Brand As New List(Of REM_Brand)
        Dim Brand_Service As New Brand_Service
        REM_Brand = Brand_Service.GetAll()
        REM_Brand.Distinct()
        ddlBrandSearch.DataSource = REM_Brand
        ddlBrandSearch.DataTextField = "BrandName"
        ddlBrandSearch.DataValueField = "Brand_ID"
        ddlBrandSearch.DataBind()
        ddlBrandSearch.Items.Insert(0, New ListItem("", ""))
    End Sub
    Sub BindCountrySearch()
        Dim REM_Country As New List(Of REM_Country)
        Dim Country_Service As New Country_Service
        REM_Country = Country_Service.GetAll()
        REM_Country.Distinct()
        ddlCountrySearch.DataSource = REM_Country
        ddlCountrySearch.DataTextField = "CountryName"
        ddlCountrySearch.DataValueField = "Country_ID"
        ddlCountrySearch.DataBind()
        ddlCountrySearch.Items.Insert(0, New ListItem("", ""))
    End Sub
    Private Sub GetDataTable()
        Try
            If Session("ListData_List") Is Nothing Then
                Dim dt_Result As New DataTable("Table1")
                dt_Result.Columns.Add("ListData_SeasonID")
                dt_Result.Columns.Add("ListData_SeasonCode")
                dt_Result.Columns.Add("ListData_StartDate")
                dt_Result.Columns.Add("ListData_EndDate")
                Session("ListData_List") = dt_Result
            End If
        Catch ex As Exception

        End Try

    End Sub
    Private Function CheckDuplicateInsert(ByVal SeasonCode As String) As Boolean

        Try
            For Each gr As GridViewRow In gv_Data_Season.Rows
                If CType(gr.Cells(2).FindControl("lblSeasonCode"), Label).Text() = SeasonCode Then
                    Return True
                End If
            Next

            Return False
        Catch ex As Exception
            Return False
        End Try
    End Function
    Private Sub AddListRow(ByVal iSeasonID As Integer, ByVal sSeasonCode As String, ByVal sStartDate As Date, ByVal sEndDate As Date)
        Try
            If iSeasonID < 1 Then
                Return
            End If
            Dim dt_Result As New DataTable
            Dim dr As DataRow
            dt_Result = CType(Session("ListData_List"), DataTable)
            dr = dt_Result.NewRow()
            dr("ListData_SeasonID") = iSeasonID
            dr("ListData_SeasonCode") = sSeasonCode
            dr("ListData_StartDate") = sStartDate
            dr("ListData_EndDate") = sEndDate
            dt_Result.Rows.Add(dr)
            Session("ListData_List") = dt_Result
        Catch ex As Exception
        End Try
    End Sub
    Private Sub BindListData(sType As String)
        Try
            Dim dt_Result As New DataTable
            dt_Result = GetListData()
            If sType = "edit" Then
                If dt_Result.Rows.Count > 0 Then
                    gv_Data_Season.DataSource = dt_Result
                    gv_Data_Season.DataBind()
                Else
                    gv_Data_Season.DataSource = Nothing
                    gv_Data_Season.DataBind()
                End If
            ElseIf sType = "view" Then
                gv_Data_Season_View.DataSource = dt_Result
                gv_Data_Season_View.DataBind()
            End If


            'ChkListResult()

        Catch ex As Exception

        End Try
    End Sub
    Private Function GetListData() As DataTable
        Dim dt_Result As New DataTable
        dt_Result = CType(Session("ListData_List"), DataTable)
        Return dt_Result
    End Function
    Sub ClearControl()
        txtFromDate.Text = ""
        txtToDate.Text = ""
        ddl_Season.SelectedIndex = 0
    End Sub
    Sub LoadCtrl(iResortID As Integer)
        Dim REM_Resort As New REM_Resort
        Dim Resort_Service As New Resort_service
        REM_Resort = Resort_Service.GetByID(iResortID)
        If Not REM_Resort Is Nothing Then
            If REM_Resort.ResortName <> "" Then
                txtResortName.Text = REM_Resort.ResortName
                HDFieldResortID.Value = iResortID

                'ddl_DepartmentofRequest.SelectedValue = ddl_DepartmentofRequest.Items.FindByText(LogonUser.Department).Value
                ddl_Brand.SelectedValue = ddl_Brand.Items.FindByValue(REM_Resort.Brand_ID).Value
                If REM_Resort.isActive Then
                    ddl_Status.SelectedValue = 1
                Else
                    ddl_Status.SelectedValue = 0
                End If
                ddl_Country.SelectedValue = ddl_Country.Items.FindByValue(REM_Resort.Country_ID).Value
                txtAddress.Text = REM_Resort.Address
                txtDescription.Text = REM_Resort.Description
                MultiView1.ActiveViewIndex = 1
            Else
                txtResortName.Text = ""
            End If
        End If
    End Sub
    Sub LoadgvSeason(ByVal iResortID As Integer)
        Dim LREM_ResortSeason As New List(Of REM_ResortSeason)
        Dim REM_Season As New REM_Season
        Dim ResortSeason_Service As New ResortSeason_service
        Dim Season_Service As New Season_Service

        ClearListRow()
        LREM_ResortSeason = ResortSeason_Service.GetByResortID(iResortID).ToList()
        For i As Integer = 0 To LREM_ResortSeason.Count - 1
            Dim sSeasonCode As String = Season_Service.GetByID(LREM_ResortSeason.Item(i).Season_ID).SeasonCode
            Dim dtStartDate As Date = LREM_ResortSeason.Item(i).StartDate
            Dim dtEndDate As Date = LREM_ResortSeason.Item(i).EndDate

            AddListRow(LREM_ResortSeason.Item(i).Season_ID, sSeasonCode, dtStartDate, dtEndDate)
        Next

    End Sub
    Sub ClearControlResort()
        txtResortName.Text = ""
        ddl_Brand.SelectedIndex = 0
        ddl_Status.SelectedIndex = 0
        ddl_Country.SelectedIndex = 0
        txtAddress.Text = ""
        txtDescription.Text = ""
        HDFieldResortID.Value = ""
    End Sub
    Function CheckInsert(ByRef sError As String) As Boolean
        CheckInsert = True
        If txtResortName.Text = "" Then
            sError = "ResortName,"
        ElseIf txtAddress.Text = "" Then
            sError &= "Address,"
        ElseIf txtDescription.Text = "" Then
            sError &= "Description,"
        End If
        If sError.Length > 1 Then
            CheckInsert = False
            sError = sError.Substring(1, sError.Length - 1)
        End If
    End Function
    Function CheckNameExisting(ByVal sResortName As String, ByVal ID As Integer) As Boolean
        Dim Resort_service As New Resort_service
        Dim LobjREM_Resort As New List(Of REM_Resort)
        LobjREM_Resort = Resort_service.GetByName(sResortName)
        If LobjREM_Resort Is Nothing Then
            Return False
        Else
            If LobjREM_Resort.Count > 0 Then
                If LobjREM_Resort.Item(0).Resort_ID = ID Then
                    Return False
                End If
                Return True
            End If
        End If
        Return False
    End Function
    Function CheckIDExistingResortSeason(ByVal iResort As Integer, ByVal iSeason As Integer) As Boolean
        Dim ResortSeason_service As New ResortSeason_service
        Dim LobjREM_ResortSeason As New List(Of REM_ResortSeason)

        LobjREM_ResortSeason = ResortSeason_service.GetByID(iResort, iSeason)
        If LobjREM_ResortSeason Is Nothing Then
            Return False
        Else
            If LobjREM_ResortSeason.Count > 0 Then
                Return True
            End If
        End If
        Return False
    End Function
    Private Sub ClearListRow()
        Try
            Session("ListData_List") = Nothing
            GetDataTable()
        Catch ex As Exception

        End Try

    End Sub
    Sub ClearControlAdd()
        txtResortName.Text = ""
        ddl_Brand.ClearSelection()
        ddl_Country.ClearSelection()
        ddl_Status.ClearSelection()
        txtAddress.Text = ""
        txtDescription.Text = ""
        ClearListRow()
        BindListData("edit")
    End Sub
#End Region
#Region "gv_data"
    Private Sub gv_Data_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles gv_Data.RowCommand
        Dim commandArgs As String = e.CommandArgument.ToString()
        Dim Resort_Service As New Resort_service
        Dim iResortID As Integer
        iResortID = CType(commandArgs, Integer)
        If e.CommandName.ToLower = "edit" Then
            LoadCtrl(iResortID)
            LoadgvSeason(iResortID)
            BindListData("edit")
        ElseIf e.CommandName.ToLower = "delete" Then
            Resort_Service.Delete(iResortID)
        ElseIf e.CommandName.ToLower = "detail" Then
            MultiView1.ActiveViewIndex = 2
            BindDataView(iResortID)
            LoadgvSeason(iResortID)
            BindListData("view")
        End If
    End Sub
    Private Sub gv_Data_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gv_Data.RowDataBound
        Try
            If e.Row.RowType = DataControlRowType.DataRow Then

                ' ''CType(e.Row.Cells(18).FindControl("chk_IMMEDIATE"), CheckBox)
                'e.Row.Cells(4).Text = Format(CType(CType(e.Row.Cells(4).FindControl("lblCreateDate"), Label).Text, Date), "dd/MM/yyyy")
                'e.Row.Cells(5).Text = Format(CType(CType(e.Row.Cells(5).FindControl("lblUpdateDate"), Label).Text, Date), "dd/MM/yyyy")
                'GetDataUtil.CDateFormat(e.Row.Cells(4).Text)
                'GetDataUtil.CDateFormat(e.Row.Cells(5).Text)

                Dim Brand_Service As New Brand_Service
                Dim REM_Brand As New List(Of REM_Brand)
                Dim iBrand As Integer = CType(e.Row.Cells(4).FindControl("lblBrand_ID"), Label).Text
                REM_Brand = Brand_Service.GetAll.Where(Function(p) p.Brand_ID = iBrand).ToList()
                e.Row.Cells(4).Text = REM_Brand.Item(0).BrandName

                Dim Country_Service As New Country_Service
                Dim REM_Country As New List(Of REM_Country)
                Dim iCountryID As Integer = CType(e.Row.Cells(6).FindControl("lblCountry_ID"), Label).Text
                REM_Country = Country_Service.GetAll.Where(Function(p) p.Country_ID = iCountryID).ToList()
                e.Row.Cells(6).Text = REM_Country.Item(0).CountryName
                'Dim User_Service As New User_Service
                'Dim LEXP_Select_REM_User_Result As New List(Of EXP_Select_REM_User_Result)
                'Dim iUserID As Integer = CType(e.Row.Cells(6).FindControl("lblUpdateUser"), Label).Text
                'LEXP_Select_REM_User_Result = User_Service.GetAll.Where(Function(p) p.User_ID = iUserID).ToList
                'e.Row.Cells(6).Text = LEXP_Select_REM_User_Result.Item(0).FullName

                e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#99CCFF'")
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;")

            End If

        Catch ex As Exception

            ' Page.ClientScript.AlertMessage(Me, "gv_Data_RowDataBound", "gv_Data_RowDataBound >>" & ex.Message)

        End Try
    End Sub
    Private Sub gv_Data_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles gv_Data.RowDeleting
        BindData()
    End Sub
    Private Sub gv_Data_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles gv_Data.RowEditing
        BindData()
    End Sub

#End Region
#Region "gv_data_Season"
    Private Sub gv_Data_Season_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles gv_Data_Season.RowCommand
        Try

            If e.CommandName = "Delete" Then
                Dim dt_Result As New DataTable
                dt_Result = GetListData()
                Dim rIndex As Integer = -1
                For Each dr As DataRow In dt_Result.Rows
                    rIndex = rIndex + 1
                    If dr("ListData_SeasonCode").ToString() = e.CommandArgument.ToString() Then
                        Exit For
                    End If
                Next
                If rIndex > -1 Then
                    dt_Result.Rows.RemoveAt(rIndex)
                End If
                Session("ListData_List") = dt_Result
                BindListData("edit")
            End If
        Catch ex As Exception

        End Try

    End Sub

    Private Sub gv_Data_Season_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gv_Data_Season.RowDataBound
        Try
            If e.Row.RowType = DataControlRowType.DataRow Then

                e.Row.Cells(3).Text = Format(CType(CType(e.Row.Cells(3).FindControl("lblStartDate"), Label).Text, Date), "dd/MM/yyyy")
                e.Row.Cells(4).Text = Format(CType(CType(e.Row.Cells(4).FindControl("lblEndDate"), Label).Text, Date), "dd/MM/yyyy")
                GetDataUtil.CDateFormat(e.Row.Cells(3).Text)
                GetDataUtil.CDateFormat(e.Row.Cells(4).Text)

                e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#99CCFF'")
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;")

            End If

        Catch ex As Exception

            ' Page.ClientScript.AlertMessage(Me, "gv_Data_RowDataBound", "gv_Data_RowDataBound >>" & ex.Message)

        End Try
    End Sub
    Private Sub gv_Data_Season_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles gv_Data_Season.RowDeleting

    End Sub
#End Region

    Protected Sub btnBackView_Click(sender As Object, e As EventArgs) Handles btnBackView.Click
        MultiView1.ActiveViewIndex = 0
        BindData()
    End Sub

    Private Sub gv_Data_Season_View_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gv_Data_Season_View.RowDataBound
        Try
            If e.Row.RowType = DataControlRowType.DataRow Then

                e.Row.Cells(2).Text = Format(CType(CType(e.Row.Cells(2).FindControl("lblStartDate"), Label).Text, Date), "dd/MM/yyyy")
                e.Row.Cells(3).Text = Format(CType(CType(e.Row.Cells(3).FindControl("lblEndDate"), Label).Text, Date), "dd/MM/yyyy")
                GetDataUtil.CDateFormat(e.Row.Cells(2).Text)
                GetDataUtil.CDateFormat(e.Row.Cells(3).Text)

                e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#99CCFF'")
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;")

            End If

        Catch ex As Exception

            ' Page.ClientScript.AlertMessage(Me, "gv_Data_RowDataBound", "gv_Data_RowDataBound >>" & ex.Message)

        End Try
    End Sub

End Class